﻿using System;
using System.Collections.Generic;
using System.Text;

using BEGDC.Utility.Configuration;

namespace BEGDC.MIS.Office
{
    public class Configuration : BEGDC.Utility.Configuration.Configuration
    {
        public Configuration()
            : base()
        {
            template_path = this["TemplatePath"];
            if (template_path.IndexOf(":\\") < 0)
            {
                template_path = System.Web.HttpContext.Current.Server.MapPath(template_path);
            }

            upload_path = this["UploadPath"];
            upload_path_relative = upload_path;
            if (upload_path.IndexOf(":\\") < 0)
            {
                upload_path = System.Web.HttpContext.Current.Server.MapPath(upload_path);
                if (!System.IO.Directory.Exists(upload_path))
                    System.IO.Directory.CreateDirectory(upload_path);
            }
            
        }

        public override string ModuleName
        {
            get
            {
                return "BEGDC.MIS.Office";
            }
        }

        private string template_path;

        private string upload_path;

        private string upload_path_relative;

        private static Configuration config;

        public static string TemplatePath
        {
            get
            {
                if (config == null)
                    config = new Configuration();
                return config.template_path;
            }
        }

        public static string UploadPath
        {
            get
            {
                if (config == null)
                    config = new Configuration();
                return config.upload_path;
            }
        }

        public static string UploadPath_Relative
        {
            get
            {
                if (config == null)
                    config = new Configuration();
                return config.upload_path_relative;
            }
        }
    }
}
